package ihm.controller;

import ihm.model.DebtModel;
import ihm.view.DebtsPanel;
import uccimpl.DebtService;
import domain.Debt;
import exceptions.InvalidParameterException;
import exceptions.NullParameterException;

public class DebtController extends Controller {
	private DebtModel debtModel;
	private DebtService debtService = DebtService.getInstance();
	
	public DebtController() {
		this.debtModel = new DebtModel();
		DebtsPanel view = new DebtsPanel(debtModel);
		this.registerView(view);
	}
	
	public Debt addDebt(Debt d) throws NullParameterException, InvalidParameterException {
		Debt debt = this.debtService.add(d);
		this.debtModel.addDebt(debt);
		
		return debt;
	}
	
	public void alertView() {
		//ChangeEvent ce = new ChangeEvent(this.debtModel);
		//TODO throw new changeevent to view
	}
}